﻿<!DOCTYPE html>
<html lang="en">
<head profile="http://a9.com/-/spec/opensearch/1.1/">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="./site.css" rel="stylesheet">
<title>crypto/sha1</title>
</head>
<body>
<div class="container">
    <h2 id="pkg-overview">package sha1</h2>
    <p><code>import "crypto/sha1"</code>
    <p>sha1包实现了SHA1哈希算法，参见<a href="http://tools.ietf.org/html/rfc3174">RFC 3174</a>。</p>
    <h3 id="pkg-index" class="section-header">Index <a class="permalink" href="#pkg-index">&para;</a></h3>
    <a href="../main.html"><h3>返回首页</h3></a>
		</br>
        <li><a href="#pkg-constants">Constants</a></li>
        <li><a href="#Sum">func Sum(data []byte) [Size]byte</a></li>
        <li><a href="#New">func New() hash.Hash</a></li>
    </ul>
    <h4 id="pkg-examples">Examples <a class="permalink" href="#pkg-index">&para;</a></h4>
    <a href="../main.html"><h3>返回首页</h3></a>
		</br>
        <li><a href="#example-New" onclick="$('#ex-New').addClass('in').removeClass('collapse').height('auto')">New</a></li>
        <li><a href="#example-Sum" onclick="$('#ex-Sum').addClass('in').removeClass('collapse').height('auto')">Sum</a></li>
    </ul>
    <h3 id="pkg-constants">Constants <a class="permalink" href="#pkg-index">&para;</a></h3>
    <pre>const <span id="BlockSize">BlockSize</span> = 64</pre>
    <p>SHA1的块大小。</p>
    <pre>const <span id="Size">Size</span> = 20</pre>
    <p>SHA1校验和的字节数。</p>
    <h3 id="Sum">func <a title="View Source" href="https://github.com/golang/go/blob/master/src/crypto/sha1/sha1.go?name=release#125">Sum</a> <a class="permalink" href="#pkg-index">&para;</a></h3>
    <pre class="funcdecl">func Sum(data []<a href="builtin.htm#byte">byte</a>) [<a href="#Size">Size</a>]<a href="builtin.htm#byte">byte</a></pre>
    <p>返回数据data的SHA1校验和。</p>
    <div class="panel-group">
        <div class="panel panel-default" id="example-Sum">
            <div class="panel-heading" onclick="document.getElementById('ex-Sum').style.display = document.getElementById('ex-Sum').style.display=='none'?'block':'none';">Example</div>
            <div id="ex-Sum" class="panel-collapse collapse">
                <div class="panel-body">
                    <pre>data := []byte(&#34;This page intentionally left blank.&#34;)
fmt.Printf(&#34;% x&#34;, sha1.Sum(data))</pre>
                    <p>Output:
                    <pre>af 06 49 23 bb f2 30 15 96 aa c4 c2 73 ba 32 17 8e bc 4a 96
</pre>
                </div>
            </div>
        </div>
    </div>
    <h3 id="New">func <a title="View Source" href="https://github.com/golang/go/blob/master/src/crypto/sha1/sha1.go?name=release#51">New</a> <a class="permalink" href="#pkg-index">&para;</a></h3>
    <pre class="funcdecl">func New() <a href="hash.htm">hash</a>.<a href="hash.htm#Hash">Hash</a></pre>
    <p>返回一个新的使用SHA1校验的hash.Hash接口。</p>
    <div class="panel-group">
        <div class="panel panel-default" id="example-New">
            <div class="panel-heading" onclick="document.getElementById('ex-New').style.display = document.getElementById('ex-New').style.display=='none'?'block':'none';">Example</div>
            <div id="ex-New" class="panel-collapse collapse">
                <div class="panel-body">
                    <pre>h := sha1.New()
io.WriteString(h, &#34;His money is twice tainted:&#34;)
io.WriteString(h, &#34; &#39;taint yours and &#39;taint mine.&#34;)
fmt.Printf(&#34;% x&#34;, h.Sum(nil))</pre>
                    <p>Output:
                    <pre>59 7f 6a 54 00 10 f9 4c 15 d7 18 06 a9 9a 2c 87 10 e7 47 bd
</pre>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>
